package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.SupplierMapper;
import com.weixing.mall.provider.model.domain.Supplier;
import com.weixing.mall.provider.model.dto.SupplierDto;
import com.weixing.mall.provider.model.vo.SupplierVo;
import com.weixing.mall.provider.service.ISupplierService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author wx
 * @Date 2019/8/6 13:56
 * @Version 1.0
 */
/**
 * <p>
 * 商品模块-供应商 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-20
 */
@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements ISupplierService {
    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public IPage<SupplierVo> selectOfPage(Page page, String supplierName) {
        return supplierMapper.selectList(page,supplierName);
    }



    @Override
    public void save(SupplierDto supplierDto) {
        Supplier supplier = new Supplier();
        BeanUtils.copyProperties(supplierDto,supplier);
        if(null==supplierDto.getId()){
            save(supplier);
        }else{
            updateById(supplier);
        }
    }
    @Override
    public void deleteAll(int[] emp) {
        supplierMapper.delAll(emp);
    }

    @Override
    public List<SupplierVo> selectAll(Integer enable) {
        return supplierMapper.selectAll(enable);
    }
}
